<template>
	<view>
		<template v-if="page_loading">
			<Loading />
		</template>
		<template v-else>
			<Empty v-if="articleList.length===0"></Empty>
			<article-list :loadlist="articleList"></article-list>
		</template>

	</view>
</template>

<script>
	import Empty from '../../components/empty/empty.vue'
	import Loading from '../../components/loading/loading.vue'
	export default {
		components: {
			Empty,
			Loading
		},
		data() {
			return {
				articleList: [],
				page: 0,
				page_loading: true,
			}
		},
		computed: {
			loginAction() {
				return this.$store.state.login.loginAction
			},
		},
		onShow() {
			if (this.loginAction) {
				this.page = 0
				this.articleList = []
				this.loadArticle();
				this.$store.commit('setLoginAction', {
					loginAction: false,
					_this: this,
				});
			}
		},
		onReady() {
			this.loadArticle();
		},
		onReachBottom() {
			this.loadArticle();
		},
		methods: {
			//加载渔夫号资讯
			loadArticle() {
				this.page = this.page + 1;
				let params = {
					page: this.page,
					limit: 10
				};
				this.$api('Article/lists', params).then(data => {
					if (data.status == 1) {
						this.loadStatus = 'loading';
						let list = data.data.article;
						for (let m in list) {
							this.articleList.push(list[m]);
						}
						if (this.page_loading) this.page_loading = false
					} else {
						this.$showToast(data.msg);
					}
				});
			}
		}
	}
</script>

<style>

</style>